/**
*  用于巡线小车的电机控制和颜色传感器的获取
*
*/

#ifndef XYXKC_I2C_H
#define XYXKC_I2C_H

#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <Wire.h> 

#define I2C_STC8H8K64U_ADDR 45  

class XYXKC_I2C
{
    public:
        uint8_t date[16];
        uint8_t relayDate[14];   
        XYXKC_I2C();
        void init();
        void begin();
        void readRelay();
        void readIO(uint8_t *date);
        void write(uint8_t h);
        String readString(uint8_t len);
        String readRelayString();
        void servoWrite(uint8_t io,uint8_t angle);
        void pwmWrite(uint8_t io,uint8_t angle);
    private:
        TwoWire *_wire;
        void _writeByte(uint8_t role,uint8_t sentData);
        uint8_t _i2caddr;
};
 
#endif   